﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace QLDAOL.Controllers
{
    public class BaseController : Controller
    {
        //
        // GET: /Base/

       
        public ActionResult RedirectIndex()
        {
            return RedirectToAction("Index", "Home", new { returnUrl = Request.Path });
        }
        public ActionResult RedirectLogon()
        {
            return RedirectToAction("Logon", "Account", new { returnUrl = Request.Path });
        }
        public ActionResult RedirectResult()
        {
            return RedirectToAction("active_result", "Account", new { returnUrl = Request.Path });
        }
        public ActionResult RedirectAdminlogon()
        {
            return RedirectToAction("login", "admin", new { returnUrl = Request.Path });
        }
        public ActionResult RedirectRegister()
        {
            return RedirectToAction("Register", "Account", new { returnUrl = Request.Path });
        }

        
    }
    public class DownloadResult : ActionResult
    {
        public string FileName { get; set; }
        public string Path { get; set; }

        public override void ExecuteResult(ControllerContext context)
        {
            context.HttpContext.Response.Buffer = true;
            context.HttpContext.Response.Clear();
            context.HttpContext.Response.AddHeader("content-disposition", "attachment; filename=" + FileName);
            context.HttpContext.Response.ContentType = "application/octet-stream";
            context.HttpContext.Response.WriteFile(context.HttpContext.Server.MapPath(Path));
        }
    }
}
